import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('../views/AboutView.vue')
  },
  {
    path: '/xxxx',
    name: 'xxxx',
    component: () => import('../views/xxxx.vue'),
    redirect:'/xxxx/shouye',
    children: [
      {
        path: 'shouye',
        name: 'shouye',
        component: () => import('../components/shouye.vue')
      },
      {
        path: 'kechen',
        name: 'kechen',
        component: () => import('../components/kechen.vue')
      },
      {
        path: 'yueke',
        name: 'yueke',
        component: () => import('../components/yueke.vue')
      },
      {
        path: 'lianxi',
        name: 'lianxi',
        component: () => import('../components/lianxi.vue')
      },
      {
        path: 'wode',
        name: 'wode',
        component: () => import('../components/wode.vue')
      },
    ]
  }
]

const router = new VueRouter({
  routes
})


// router.beforeEach((to,from,next)=>{
//   if (to.path!='/xxxx') {
//     var token=localStorage.getItem('token')
//     if (token) {
//       next()
//     }else{
//       next('/xxxx')
//     }
//   }else{
//     next()
//   }
// })
export default router
